<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.1/theme-chalk/index.min.css" rel="stylesheet">
    <link href="/index.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet">
    <style>
        body{
            background: #529EEB;
        }
        .el-message-box {
            display: inline-block;
            min-width: 420px !important;
            width: 640px !important;
        }

        [v-cloak] {
            display: none;
        }

        .box-card {
            margin-bottom: 20px;
        }

        .el-input__inner {
            width: 400px !important;
        }

        .el-input {
            width: 400px !important;
        }

        .el-input-number {
            width: 400px !important;
        }

        .popover [class*=" el-icon-"], .popover [class^=el-icon-] {
            font-size: 24px;
            line-height: 40px;
            display: inline-block;
            float: right;
            /*margin-bottom: 15px;*/
            color: #606266;
            margin: 0 !important;
            padding: 0 !important;
        }

        .el-date-picker__editor-wrap .el-input__inner {
            width: 150px !important;
        }

        .el-date-picker__editor-wrap .el-input {
            width: 150px !important;
        }


    </style>
</head>
<body>
<div id="app" v-cloak>
    <!--  <el-card  shadow="never">-->

    <el-container>
        <!--  <el-aside width="200px"></el-aside>-->
        <el-container>
            <el-header></el-header>
            <el-main>
                <el-card shadow="never" style="width: 1000px;margin: 0 auto">
                    <el-page-header slot="header" content="机器猫">
                    </el-page-header>
                    <el-tabs type="card">
                        <el-tab-pane label="参数配置">
                            <el-form ref="form" :model="form" label-suffix=" = " label-width="240px"
                                     style="width: 900px;">
                                <el-alert
                                        title="不清楚参数的意思 可以点击最后面的感叹号图标!"
                                        type="info"
                                        center
                                        show-icon>
                                </el-alert>
                                <el-alert
                                        title="请注意区分 HECO 和 BSC 哦!"
                                        type="success"
                                        center
                                        show-icon>
                                </el-alert>
                                <el-form-item label="去中心化交易所">
                                    <el-select
                                            v-model="form.platform"
                                            filterable
                                            default-first-option
                                            @change="changePlatform"
                                            placeholder="请选择">
                                        <el-option
                                                v-for="item in platform"
                                                :key="item.value"
                                                :label="item.label"
                                                :value="item.value">
                                        </el-option>
                                    </el-select>
                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover"
                                    >
                                        <p>请注意区分 HECO 和 BSC 哦</p>

                                        <p>HECO官方授权解除工具:</p>
                                        <p>https://hecoinfo.com/tokenapprovalchecker</p>
                                        <p>BSC官方授权解除工具：</p>
                                        <p>https://bscscan.com/tokenapprovalchecker</p>

                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>

                                </el-form-item>

                                <el-alert
                                        title="节点速度会严重影响购买效率!请提前测试或使用境外网络!可以输入自己测试后的RPC节点!"
                                        type="warning"
                                        center
                                        show-icon>
                                </el-alert>
                                <el-alert
                                        title="作者暂时提供免费代理节点! 服务器带宽资源有限! 后续提供专用节点!"
                                        type="success"
                                        center
                                        show-icon>
                                </el-alert>
                                <el-form-item label="RPC地址" prop="rpc"
                                              :rules="[ { required: true, message: '请选择RPC地址', trigger: ['change','blur'] } ]">
                                    <!--                            <el-input v-model="form.rpc"-->
                                    <!--                                      placeholder="默认 https://bsc-dataseed.binance.org"></el-input>-->
                                    <!--                          rpclist-->
                                    <el-select
                                            v-model="form.rpc"
                                            filterable
                                            allow-create
                                            default-first-option
                                            placeholder="请选择RPC地址">
                                        <el-option
                                                v-for="item in rpclist"
                                                :key="item"
                                                :label="item"
                                                :value="item">
                                        </el-option>
                                    </el-select>

                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover">
                                        <p>作者暂时提供免费代理节点:</p>

                                        <span>火币:</span>
                                        <span>http://blockchains.tools/heco-rpc/</span><br/>
                                        <span>http://blockchains.tools/heco-rpc1/</span><br/>
                                        <br>
                                        <span>币安智能链:</span>
                                        <span>http://blockchains.tools/bsc-rpc/</span><br/>
                                        <span>http://blockchains.tools/bsc-rpc1/</span><br/>
                                        <span>http://blockchains.tools/bsc-rpc2/</span><br/>
                                        <span>http://blockchains.tools/bsc-rpc3/</span><br/>
                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>

                                </el-form-item>
                                <el-form-item label="去中心化交易所 工厂地址">
                                    <el-input v-model="form.factory" disabled></el-input>
                                </el-form-item>
                                <el-form-item label="去中心化交易所 路由地址">
                                    <el-input v-model="form.router" disabled></el-input>
                                </el-form-item>

                                <el-form-item label="用来兑换的币" prop="tokenIn"
                                              :rules="[ { required: true, message: '请选择用来兑换的币', trigger: ['change','blur'] } ]">

                                    <el-select
                                            v-model="form.tokenIn"
                                            filterable
                                            placeholder="请选择用来兑换的币">
                                        <el-option
                                                v-for="item in options"
                                                :key="item.value"
                                                :label="item.label"
                                                :value="item.value">
                                        </el-option>
                                    </el-select>

                                </el-form-item>

                                <el-alert
                                        title="如果不知道合约地址!可以在软件启动后输入!"
                                        type="success"
                                        center
                                        show-icon>
                                </el-alert>
                                <el-form-item label="兑换到的币 合约地址">
                                    <el-input v-model="form.tokenOut"></el-input>

                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover"
                                            content="请输入你要 兑换到的币 合约地址">
                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>
                                </el-form-item>
                                <!--  <el-form-item label="钱包地址" prop="recipient"-->
                                <!--  :rules="[ { required: true, message: '请输入钱包地址', trigger: ['change','blur'] } ]">-->
                                <!--  <el-input v-model="form.recipient"></el-input>-->
                                <!--  </el-form-item>-->

                                <el-alert
                                        title="尽量创建新的小号钱包使用!自动通过助记词获取钱包地址!避免输入错误导致资金丢失!"
                                        type="warning"
                                        center
                                        show-icon>
                                </el-alert>
                                <el-form-item label="钱包助记词" prop="mnemonic"
                                              :rules="[ { required: true, message: '请输入钱包助记词', trigger: ['change','blur'] } ]">
                                    <el-input v-model="form.mnemonic" show-password></el-input>
                                </el-form-item>

                                <el-form-item label="消耗用来兑换的币数量">
                                    <el-input-number v-model="form.amountIn" controls-position="right" :step="0.001"
                                                     :min="0.001"
                                                     :max="99999999"></el-input-number>
                                </el-form-item>

                                <el-form-item label="高级配置">
                                    <el-switch v-model="form.advanced"></el-switch>
                                </el-form-item>


                                <transition name="el-fade-in-linear">
                                    <div v-if="form.advanced">


                                        <el-alert
                                                title="高级配置打开后可能会影响买入!启用请做好两手准备!"
                                                type="warning"
                                                center
                                                show-icon>
                                        </el-alert>

                                        <el-divider>高级配置</el-divider>
                                        <el-alert
                                                title="大于0时 买入前进行检查!会影响买入速度几秒!"
                                                type="info"
                                                center
                                                show-icon>
                                        </el-alert>
                                        <!--                                        <el-form-item label="最小流动性池金额 $">-->
                                        <!--                                            <el-input-number v-model="form.poolSize" controls-position="right"-->
                                        <!--                                                             :step="1" :min="0"-->
                                        <!--                                                             :precision="0"-->
                                        <!--                                                             :max="99999999"></el-input-number>-->
                                        <!--                                            <el-tag effect="dark" type="success">$</el-tag>-->

                                        <!--                                            <el-popover-->
                                        <!--                                                    placement="right"-->
                                        <!--                                                    title="提示"-->
                                        <!--                                                    width="400"-->
                                        <!--                                                    trigger="hover"-->
                                        <!--                                                    class="popover"-->
                                        <!--                                                    content="流动性池金额 $ 大于当前配置时 才能触发购买! 0 不限制">-->
                                        <!--                                                <i class="el-icon-info" slot="reference"></i>-->
                                        <!--                                            </el-popover>-->
                                        <!--                                        </el-form-item>-->

                                        <el-form-item label="限价百分比以内买入">
                                            <el-input-number v-model="form.limitInPercentage" controls-position="right"
                                                             :step="1"
                                                             :precision="0"
                                                             :min="10" :max="9999"></el-input-number>
                                            <el-tag effect="dark">%</el-tag>
                                            <el-popover
                                                    placement="right"
                                                    title="提示"
                                                    width="400"
                                                    trigger="hover"
                                                    class="popover"
                                                    content="示例 填写 300 表示 价格超过软件第一次获取成功价格 300% 就取消买入! 默认 100 为不限制! 填写 10 表示 价格低于软件第一次获取成功价格 10% 才能买入!">
                                                <i class="el-icon-info" slot="reference"></i>
                                            </el-popover>
                                        </el-form-item>

                                        <!--                                        <el-form-item label="最高购买单价 $">-->
                                        <!--                                            <el-input-number v-model="form.amountOutPriceMax" controls-position="right"-->
                                        <!--                                                             :step="0.00000001"-->
                                        <!--                                                             :precision="8"-->
                                        <!--                                                             :min="0"-->
                                        <!--                                                             :max="999999"></el-input-number>-->
                                        <!--                                            <el-tag effect="dark" type="success">$</el-tag>-->

                                        <!--                                            <el-popover-->
                                        <!--                                                    placement="right"-->
                                        <!--                                                    title="提示"-->
                                        <!--                                                    width="400"-->
                                        <!--                                                    trigger="hover"-->
                                        <!--                                                    class="popover"-->
                                        <!--                                                    content="当1BNB买入的数量少于当前配置的数量时 终止购买! 0 不限制! 如果不清楚 请填0!">-->
                                        <!--                                                <i class="el-icon-info" slot="reference"></i>-->
                                        <!--                                            </el-popover>-->
                                        <!--                                        </el-form-item>-->

                                        <!--                                        <el-form-item label="最低购买单价 $">-->
                                        <!--                                            <el-input-number v-model="form.amountOutPriceMin" controls-position="right"-->
                                        <!--                                                             :step="0.00000001"-->
                                        <!--                                                             :precision="8"-->
                                        <!--                                                             :min="0"-->
                                        <!--                                                             :max="999999"></el-input-number>-->
                                        <!--                                            <el-tag effect="dark" type="success">$</el-tag>-->

                                        <!--                                            <el-popover-->
                                        <!--                                                    placement="right"-->
                                        <!--                                                    title="提示"-->
                                        <!--                                                    width="400"-->
                                        <!--                                                    trigger="hover"-->
                                        <!--                                                    class="popover"-->
                                        <!--                                                    content="当1BNB买入的数量少于当前配置的数量时 终止购买! 0 不限制! 如果不清楚 请填0!">-->
                                        <!--                                                <i class="el-icon-info" slot="reference"></i>-->
                                        <!--                                            </el-popover>-->
                                        <!--                                        </el-form-item>-->

                                    </div>
                                </transition>

                                <el-divider>标准配置</el-divider>

                                <el-form-item label="滑点 买入">
                                    <el-input-number v-model="form.slippage" controls-position="right" :step="1"
                                                     :min="1"
                                                     :max="99"></el-input-number>
                                    <el-tag effect="dark">%</el-tag>

                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover"
                                            content="建议抢购时调到40以上 可以突破49的限制">
                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>

                                </el-form-item>
                                <el-form-item label="滑点 卖出">
                                    <el-input-number v-model="form.slippage1" controls-position="right" :step="1"
                                                     :min="1"
                                                     :max="99"></el-input-number>
                                    <el-tag effect="dark">%</el-tag>

                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover"
                                            content="可以突破49的限制">
                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>

                                </el-form-item>

                                <el-alert
                                        title=""
                                        type="success"
                                        center
                                        show-icon>
                                    <div slot="title">
                                        当前计算的 汽油费 预计为 <span
                                            style="color: deeppink">{{Math.round(gas * 10000) / 10000
                                        }} <span v-if="form.type=='bsc'">BNB</span><span v-else>HT</span></span> 请保证余额大于
                                        <span style="color: deeppink"
                                              v-if="form.autoSale">{{ Math.round((gas * 2 + form.amountIn) * 10000) / 10000
                                            }} <span v-if="form.type=='bsc'">BNB</span><span v-else>HT</span></span>
                                        <span style="color: deeppink"
                                              v-else>{{ Math.round(gas * 10000) / 10000 + form.amountIn
                                            }} <span v-if="form.type=='bsc'">BNB</span><span v-else>HT</span></span>
                                        避免下单失败
                                    </div>
                                </el-alert>
                                <el-alert
                                        v-if="form.autoSale"
                                        title=""
                                        type="warning"
                                        center
                                        show-icon>
                                    <div slot="title">
                                        当前已配置自动卖出! 请预留卖出时的<span
                                            style="color: deeppink">{{Math.round(gas * 10000) / 10000
                                        }} <span v-if="form.type=='bsc'">BNB</span><span v-else>HT</span></span> 汽油费!
                                    </div>
                                </el-alert>

                                <el-form-item label="GAS 费(gwei)">
                                    <el-input-number v-model="form.gasPrice" controls-position="right" :step="1"
                                                     :min="5"
                                                     :max="999"></el-input-number>
                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover"
                                            content="建议抢购时调到6以上">
                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>
                                </el-form-item>
                                <el-form-item label="GAS 限额">
                                    <el-input-number v-model="form.gasLimit" controls-position="right" :step="10000"
                                                     :min="300000" :max="1000000"></el-input-number>
                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover"
                                            content="建议抢购时调到400000以上">
                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>
                                </el-form-item>

                                <!--  triggerTime-->
                                <el-form-item label="定时抢购时间">
                                    <el-date-picker
                                            v-model="form.triggerTime"
                                            type="datetime"
                                            value-format="yyyy-MM-dd HH:mm:ss"
                                            placeholder="选择定时抢购时间">
                                    </el-date-picker>
                                </el-form-item>

                                <el-form-item label="重试次数">
                                    <el-input-number v-model="form.retryCount" controls-position="right" :step="1"
                                                     :min="1" :max="10000000"></el-input-number>
                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover"
                                            content="如果项目方没准时添加流动性 会自动重试次数">
                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>
                                </el-form-item>
                                <el-form-item label="重试间隔 毫秒">
                                    <el-input-number v-model="form.retryInterval" controls-position="right" :step="100"
                                                     :min="1" :max="1000000"></el-input-number>
                                    <el-popover
                                            placement="right"
                                            title="提示"
                                            width="400"
                                            trigger="hover"
                                            class="popover"
                                            content="如果项目方没准时添加流动性 会自动重试间隔">
                                        <i class="el-icon-info" slot="reference"></i>
                                    </el-popover>
                                </el-form-item>

                                <el-alert v-if="form.autoSale"
                                          title="自动卖出会自动授权卖出的数量 !"
                                          type="success"
                                          center
                                          show-icon>
                                </el-alert>
                                <el-form-item label="自动卖出">
                                    <el-switch v-model="form.autoSale"
                                               active-text="是"
                                               inactive-text="否"></el-switch>
                                </el-form-item>

                                <template v-if='form.autoSale'>
                                    <el-form-item label="自动卖出 类型">
                                        <el-switch v-model="form.autoSaleType"
                                                   active-value="1"
                                                   inactive-value="0"
                                                   active-text="收益率"
                                                   inactive-text="时间"></el-switch>
                                    </el-form-item>

                                    <template v-if='form.autoSaleType === "1"'>
                                        <el-alert
                                                title="当前收益率不计算滑点!获取最新的价格进行计算!可能卖出时收益率有所降低!"
                                                type="success"
                                                center
                                                show-icon>
                                        </el-alert>
                                        <el-alert
                                                title="会按照 重试间隔 毫秒 一直监控当前价格直到达到触发收益率!"
                                                type="warning"
                                                center
                                                show-icon>
                                        </el-alert>

                                        <el-form-item label="自动卖出 触发收益率">
                                            <el-input-number v-model="form.autoSaleTimes" controls-position="right"
                                                             :step="1"
                                                             :min="10" :max="99999"></el-input-number>
                                            <el-tag effect="dark">%</el-tag>
                                            <el-popover
                                                    placement="right"
                                                    title="提示"
                                                    width="400"
                                                    trigger="hover"
                                                    class="popover"
                                                    content="按照买入的成本计算收益率 不计算滑点 100% 等于成本">
                                                <i class="el-icon-info" slot="reference"></i>
                                            </el-popover>
                                        </el-form-item>

                                    </template>
                                    <template v-if='form.autoSaleType === "0"'>

                                        <el-form-item label="自动卖出间隔 毫秒">
                                            <el-input-number v-model="form.autoSaleInterval" controls-position="right"
                                                             :step="100"
                                                             :min="100" :max="1000000"></el-input-number>
                                        </el-form-item>
                                    </template>

                                    <el-form-item label="自动卖出 持仓百分比">
                                        <el-input-number v-model="form.autoSalePercentage" controls-position="right"
                                                         :step="1"
                                                         :min="1" :max="100"></el-input-number>
                                        <el-tag effect="dark">%</el-tag>
                                        <el-popover
                                                placement="right"
                                                title="提示"
                                                width="400"
                                                trigger="hover"
                                                class="popover"
                                                content="达到 自动卖出 触发收益率 时卖出多少持仓">
                                            <i class="el-icon-info" slot="reference"></i>
                                        </el-popover>
                                    </el-form-item>

                                </template>

                                <el-form-item>
                                    <el-button type="primary" @click="submit">确认修改</el-button>
                                    <el-button>取消</el-button>
                                </el-form-item>
                            </el-form>
                        </el-tab-pane>
                        <el-tab-pane label="成为科学家">
                            <!--                            <p>敬请期待!</p>-->

                            <el-row :gutter="20">
                                <el-col :span="12">
                                    <el-row :gutter="20">


                                        <el-col :span="24">
                                            <el-card shadow="always" class="box-card" header="激活新钱包">
                                                <el-form ref="createUserInfoForm" :model="createUserInfoForm"
                                                         label-width="120px"
                                                         style="width: 100%" label-position="top">
                                                    <el-form-item label="新钱包地址" prop="address"
                                                                  :rules="[ { required: true, message: '请输入新钱包地址', trigger: ['change','blur'] } ]"
                                                    >
                                                        <el-input v-model="createUserInfoForm.address"
                                                                  placeholder='请输入新钱包地址'
                                                                  maxlength="42"></el-input>
                                                    </el-form-item>
                                                    <el-alert
                                                            title="如果没有邀请人钱包地址,请填写官方钱包地址: 0x2D776847832ef043Ed5555391B63eD2cDf625C9f"
                                                            type="success"
                                                            center
                                                            show-icon>
                                                    </el-alert>
                                                    <el-form-item label="邀请人钱包地址" prop="inviteAddress"
                                                                  :rules="[ { required: true, message: '请输入邀请人钱包地址', trigger: ['change','blur'] } ]"
                                                    >
                                                        <el-input v-model="createUserInfoForm.inviteAddress"
                                                                  placeholder="官方钱包地址: 0x2D776847832ef043Ed5555391B63eD2cDf625C9f"
                                                                  maxlength="42"></el-input>
                                                    </el-form-item>

                                                    <el-form-item>
                                                        <el-button type="primary" @click="createUserInfo">激活新钱包
                                                        </el-button>
                                                        <el-button>取消</el-button>
                                                    </el-form-item>
                                                </el-form>

                                            </el-card>
                                        </el-col>
                                    </el-row>
                                </el-col>
                                <el-col :span="12">

                                    <el-col :span="24">
                                        <el-card shadow="always" class="box-card" header="激活CDK">
                                            <el-form ref="activeCdkInfoForm" :model="activeCdkInfoForm"
                                                     label-width="120px"
                                                     style="width: 100%" label-position="top">

                                                <el-form-item label="钱包地址" prop="address"
                                                              :rules="[ { required: true, message: '请输入钱包地址! 新钱包会自动激活哦!', trigger: ['change','blur'] } ]">

                                                    <el-input v-model="activeCdkInfoForm.address"
                                                              placeholder='请输入钱包地址! 新钱包会自动激活哦!'
                                                              maxlength="42"></el-input>
                                                </el-form-item>
                                                <el-form-item label="CDK" prop="cdk"
                                                              :rules="[ { required: true, message: '请输入CDK', trigger: ['change','blur'] } ]">

                                                    <el-input v-model="activeCdkInfoForm.cdk" placeholder='请输入CDK'
                                                              maxlength="20"></el-input>
                                                </el-form-item>
                                                <el-alert
                                                        title="如果没有邀请人钱包地址,请填写官方钱包地址: 0x2D776847832ef043Ed5555391B63eD2cDf625C9f"
                                                        type="success"
                                                        center
                                                        show-icon>
                                                </el-alert>
                                                <el-form-item label="邀请人钱包地址" prop="inviteAddress"
                                                              :rules="[ { required: true, message: '请输入邀请人钱包地址', trigger: ['change','blur'] } ]"
                                                >
                                                    <el-input v-model="activeCdkInfoForm.inviteAddress"
                                                              placeholder="官方钱包地址: 0x2D776847832ef043Ed5555391B63eD2cDf625C9f"
                                                              maxlength="42"></el-input>
                                                </el-form-item>

                                                <el-form-item>
                                                    <el-button type="primary" @click="activeCdkInfo">激活CDK
                                                    </el-button>
                                                    <el-button>取消</el-button>
                                                </el-form-item>
                                            </el-form>

                                        </el-card>
                                    </el-col>
                                </el-col>
                            </el-row>
                        </el-tab-pane>
                    </el-tabs>
                    <!--  </el-card>-->
                </el-card>
            </el-main>
            <el-footer></el-footer>
        </el-container>
    </el-container>

</div>
</body>
<!-- import Vue before Element -->
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/vue-resource/1.5.2/vue-resource.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.0/index.min.js"></script>
<!--<script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.0/locale/zh-CN.min.js"></script>-->
<script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<!--<script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/locale/zh-cn.min.js"></script>-->
<script src="https://cdn.bootcdn.net/ajax/libs/json5/0.5.1/json5.min.js"></script>
<!--<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>-->

<script>
    // let moment = require("moment");

    new Vue({
        el: '#app',
        data: function () {
            return {
                dialogVisible: true,
                show: true,
                welcome: '123123',
                createUserInfoForm: {
                    address: '',
                    inviteAddress: '',
                },
                activeCdkInfoForm: {
                    address: '',
                    cdk: '',
                    inviteAddress: '',
                },
                form: {
                    host: 'http://blockchains.tools:8080/',
                    platform: '',
                    type: '',
                    rpc: '',
                    tokenIn: '',
                    tokenOut: '',
                    factory: '',
                    router: '',
                    recipient: '',
                    mnemonic: '',
                    // poolSize: '',
                    // tryAmountIn: '',
                    amountIn: '',
                    amountOutPrice: '',
                    amountOutAmount: '',
                    slippage: '',
                    gasPrice: '',
                    gasLimit: '',
                    triggerTime: '',
                    retryCount: '',
                    retryInterval: '',
                    needApprove: false,
                    autoSale: false,
                    autoSaleType: '',
                    autoSaleInterval: '',
                    autoSaleTimes: '',
                    autoSalePercentage: '',

                },
                rpclists: {
                    heco: [
                        'https://http-mainnet.hecochain.com',
                        'https://http-mainnet-node.huobichain.com'
                    ],
                    bsc: [
                        'http://blockchains.tools/bsc-rpc/',
                        'http://blockchains.tools/bsc-rpc1/',
                        'http://blockchains.tools/bsc-rpc2/',
                        'http://blockchains.tools/bsc-rpc3/',
                        'https://bsc-dataseed.binance.org/',
                        'https://bsc-dataseed1.defibit.io/',
                        'https://bsc-dataseed1.ninicoin.io/',
                    ]
                },
                rpclist: [],
                options: [],
                tokenOuts: {
                    heco: [
                        {
                            value: '0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f',
                            label: 'HT'
                            // }, {
                            //     value: '0xa71edc38d189767582c38a3145b5873052c3e47a',
                            //     label: 'USDT-HECO'
                        }
                    ],
                    bsc: [
                        {
                            value: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',
                            label: 'BNB'
                            // }, {
                            //     value: '0x55d398326f99059ff775485246999027b3197955',
                            //     label: 'USDT-BSC'
                        }
                    ]
                },
                platform: [
                    {
                        type: 'heco',
                        value: 'mdex-heco',
                        label: 'MDEX HECO',
                        factory: '0xb0b670fc1F7724119963018DB0BfA86aDb22d941',
                        router: '0xED7d5F38C79115ca12fe6C0041abb22F0A06C300',
                        // }, {
                        //     type: 'heco',
                        //     value: 'pipi-heco',
                        //     label: '皮皮虾 HECO',
                        //     factory: '0x979efe7ca072b72d6388f415d042951ddf13036e',
                        //     router: '0xBe4AB2603140F134869cb32aB4BC56d762Ae900B',
                        // }, {
                        //     type: 'heco',
                        //     value: 'bxh-heco',
                        //     label: '笨小孩 HECO',
                        //     factory: '',
                        //     router: '0x00eFB96dBFE641246E961b472C0C3fC472f6a694',
                    }, {
                        type: 'bsc',
                        value: 'mdex-bsc',
                        label: 'MDEX BSC',
                        factory: '0x3cd1c46068daea5ebb0d3f55f6915b10648062b8',
                        router: '0x7DAe51BD3E3376B8c7c4900E9107f12Be3AF1bA8',
                    }, {
                        type: 'bsc',
                        value: 'pancakeswap-v2',
                        label: '薄饼 V2 BSC',
                        factory: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73',
                        router: '0x10ED43C718714eb63d5aA57B78B54704E256024E',
                        // }, {
                        //     type: 'bsc',
                        //     value: 'pancakeswap-v1',
                        //     label: '薄饼 V1 BSC',
                        //     // factory: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73',
                        //     router: '0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F',
                    }, {
                        type: 'bsc',
                        value: 'bakeryswap',
                        label: '面包 BSC',
                        factory: '0x01bF7C66c6BD861915CdaaE475042d3c4BaE16A7',
                        router: '0xCDe540d7eAFE93aC5fE6233Bee57E1270D3E330F',
                        // }, {
                        //  value: 'burgerswap',
                        //  label: 'BurgerSwap',
                        //  factory: '',
                        //  router: '0x9FdC672a33f34675253041671abd214F2387b7aB',
                    }
                ],
            };
        },
        computed: {
            gas: function () {
                return this.form.gasPrice * this.form.gasLimit / 1000000000;
            },
            amountOutAmountString: function () {
                return this.priceString(2, this.form.amountOutAmount)
            },
            amountOutPriceString: function () {
                return this.priceString(2, this.form.amountOutPrice)
            },
            amountOutPriceMaxString: function () {
                return this.priceString(8, this.form.amountOutPriceMax)
            },
            amountOutPriceMinString: function () {
                return this.priceString(8, this.form.amountOutPriceMin)
            }
        },
        methods: {
            priceString(decimals, amount) {

                let
                    decPoint = '.',
                    thousandsSep = ','

                // this.form.amountOutPrice = (this.form.amountOutPrice + '').replace(/[^0-9+-Ee.]/g, '')
                let n = !isFinite(+amount) ? 0 : +amount
                let prec = !isFinite(+decimals) ? 0 : Math.abs(decimals)
                let sep = (typeof thousandsSep === 'undefined') ? ',' : thousandsSep
                let dec = (typeof decPoint === 'undefined') ? '.' : decPoint
                let s = ''
                let toFixedFix = function (n, prec) {
                    let k = Math.pow(10, prec)
                    return '' + Math.ceil(n * k) / k
                }
                s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.')
                let re = /(-?\d+)(\d{3})/
                while (re.test(s[0])) {
                    s[0] = s[0].replace(re, '$1' + sep + '$2')
                }
                if ((s[1] || '').length < prec) {
                    s[1] = s[1] || ''
                    s[1] += new Array(prec - s[1].length + 1).join('0')
                }

                return s.join(dec)
            }

            ,
            changePlatform(val) {
                console.log(val);

                // 修改 路由和支持的币 和 RPC 地址

                for (let platformKey of this.platform) {
                    debugger
                    if (platformKey.value === val) {

                        this.form.router = platformKey.router

                        // 获取 公链
                        let type = platformKey.type

                        this.rpclist = this.rpclists[type];
                        this.options = this.tokenOuts[type];

                        if (this.form.type != type) {
                            this.form.type = type;
                            this.form.rpc = null;
                            this.form.tokenIn = null;
                            this.form.mnemonic = null;
                            this.form.tokenOut = null;
                        }


                        // this.form.factory = platformKey.factory
                        break
                    }
                }


            },
            async submit() {

                this.$refs.form.validate(async (valid) => {
                    if (valid) {
                        const res = await this.$http.post('/edit_schedule_bot_config', this.form);
                        console.log(res);
                        if (res.status === 200) {
                            this.$message.success('参数配置成功!可以关闭软件了!');

                            this.$confirm(`参数配置成功! 建议抢购开始时同时进行手工薄饼抢购! 避免参数错误导致买入失败错过机会!`, '提示', {
                                confirmButtonText: '确定关闭',
                                cancelButtonText: '取消关闭',
                                type: 'success'
                            })
                                .then(() => {
                                    window.open('', '_self')
                                        .close();
                                    // this.$message({
                                    //  type: 'success',
                                    //  message: '删除成功!'
                                    // });
                                })
                                .catch(() => {
                                    // this.$message({
                                    //  type: 'info',
                                    //  message: '已取消删除'
                                    // });
                                });
                        }
                    } else {

                        return false;
                    }
                });

            },
            async createUserInfo() {

                this.$refs.createUserInfoForm.validate(async (valid) => {
                    if (valid) {
                        debugger
                        const res = await this.$http.post(this.form.host + 'tools/createUserInfo', this.createUserInfoForm);
                        console.log(res);
                        if (res.status == 200) {
                            debugger
                            let result = res.data;

                            console.log(result);

                            if (result.code == 200) {
                                this.$message.success(`激活新钱包地址成功!免费赠送${result.data.remainingPurchases}次抢购次数!快去体验吧!`);

                                this.$notify.success({
                                    title: '激活成功!',
                                    message: `激活新钱包地址成功!免费赠送${result.data.remainingPurchases}次抢购次数!快去体验吧!`,
                                    dangerouslyUseHTMLString: true,
                                    showClose: true,
                                    duration: 0,
                                    offset: 200
                                });

                            } else {
                                this.$message.error(`当前电脑仅支持激活一个新钱包哦!`);
                            }
                        }
                    } else {

                        return false;
                    }
                });

            },
            async activeCdkInfo() {

                this.$refs.activeCdkInfoForm.validate(async (valid) => {
                    if (valid) {
                        debugger
                        const res = await this.$http.post(this.form.host + 'tools/activeCdkInfo', this.activeCdkInfoForm);
                        console.log(res);
                        if (res.status == 200) {
                            debugger
                            let result = res.data;
                            console.log(result);

                            if (result.code == 200) {
                                this.$message.success(`激活钱包白名单地址成功! 到期时间为: ${moment(result.data.expireTime)
                                    .format("YYYY-MM-DD HH:mm:ss")}! 快去体验吧!`);

                                this.$notify.success({
                                    title: 'CDK激活成功!',
                                    message: `激活钱包白名单地址成功! 到期时间为: ${moment(result.data.expireTime)
                                        .format("YYYY-MM-DD HH:mm:ss")}! 快去体验吧!`,
                                    dangerouslyUseHTMLString: true,
                                    showClose: true,
                                    duration: 0,
                                    offset: 200
                                });

                            } else {
                                this.$message.error(`激活CDK失败! 失败原因: ${result.msg}`);
                            }
                        }
                    } else {

                        return false;
                    }
                });

            }
        },
        async created() {
            const res = await this.$http.get('/schedule_bot_config.json');

            console.log(res);
            this.form = JSON5.parse(res.bodyText);

            this.changePlatform(this.form.platform);

            if (!this.form.host) {
                this.form.host = 'http://blockchains.tools:8080/';
            }

            console.log(this.form);

            debugger


            this.$confirm(`欢迎使用 机器猫 官方正式版!<br/>新钱包地址可在页面顶部<span style="color: dodgerblue">成为科学家</span>页面<span style="color: deepskyblue">激活新钱包</span>处激活免费体验次数!<br/>每推荐一名付费用户，赠送免费不限次数使用一天!<br/>本脚本不限速毫秒级反应，使用外国服务器效果更佳!`, '上线福利!', {
                dangerouslyUseHTMLString: true,
                confirmButtonText: '确定',
                cancelButtonText: '好的',
                type: 'success'
            })
                .then(() => {
                    //
                    // this.$confirm(`本软件已开通电报群! 欢迎大家加入! <br/> 机器猫 官方电报群: <a type="primary" href="https://t.me/blockchains_tools" target="_blank">https://t.me/blockchains_tools</a>`, '加入组织', {
                    //     dangerouslyUseHTMLString: true,
                    //     confirmButtonText: '加入组织',
                    //     cancelButtonText: '我知道了',
                    //     type: 'success'
                    // })
                    //     .then(() => {
                    //         window.open('https://t.me/blockchains_tools', '_blank');
                    //
                    //     })
                    //     .catch(() => {
                    //
                    //     });

                })
                .catch(() => {
                    // this.$confirm(`本软件已开通电报群! 欢迎大家加入! <br/> 机器猫 官方电报群: <a type="primary" href="https://t.me/blockchains_tools" target="_blank">https://t.me/blockchains_tools</a>`, '加入组织', {
                    //     dangerouslyUseHTMLString: true,
                    //     confirmButtonText: '加入组织',
                    //     cancelButtonText: '我知道了',
                    //     type: 'success'
                    // })
                    //     .then(() => {
                    //         window.open('https://t.me/blockchains_tools', '_blank');
                    //
                    //     })
                    //     .catch(() => {
                    //
                    //     });
                });

            this.$notify.success({
                title: '上线福利!',
                message: `欢迎使用 机器猫 官方正式版!<br/>新钱包地址可在页面顶部<span style="color: dodgerblue">成为科学家</span>页面<span style="color: deepskyblue">激活新钱包</span>处激活免费体验次数!<br/>每推荐一名付费用户，赠送免费不限次数使用一天!<br/>本脚本不限速毫秒级反应，使用外国服务器效果更佳!`,
                dangerouslyUseHTMLString: true,
                showClose: true,
                duration: 0,
                offset: 150
            });

            // this.$notify.success({
            //     title: '电报群通知!',
            //     message: '本软件已开通电报群! 欢迎大家加入! <br/> 机器猫 官方电报群: <a type="primary" href="https://t.me/blockchains_tools" target="_blank">https://t.me/blockchains_tools</a>',
            //     dangerouslyUseHTMLString: true,
            //     showClose: true,
            //     duration: 0
            // });


        }
    });
</script>
</html>
